package com.luckyframe.project.jmeter.jmeterNodeJobRel.controller;

import com.luckyframe.common.utils.poi.ExcelUtil;
import com.luckyframe.framework.aspectj.lang.annotation.Log;
import com.luckyframe.framework.aspectj.lang.enums.BusinessType;
import com.luckyframe.framework.web.controller.BaseController;
import com.luckyframe.framework.web.domain.AjaxResult;
import com.luckyframe.framework.web.page.TableDataInfo;
import com.luckyframe.project.jmeter.jmeterNodeJobRel.domain.JmeterNodeJobRel;
import com.luckyframe.project.jmeter.jmeterNodeJobRel.service.IJmeterNodeJobRelService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 节点任务 信息操作处理
 * 
 * @author lancelot
 * @date 2020-12-07
 */
@Controller
@RequestMapping("/jmeter/jmeterNodeJobRel")
public class JmeterNodeJobRelController extends BaseController
{
    private String prefix = "jmeter/jmeterNodeJobRel";
	
	@Autowired
	private IJmeterNodeJobRelService jmeterNodeJobRelService;
	
	@RequiresPermissions("jmeter:jmeterNodeJobRel:view")
	@GetMapping()
	public String jmeterNodeJobRel()
	{
	    return prefix + "/jmeterNodeJobRel";
	}
	
	/**
	 * 查询节点任务列表
	 */
	@RequiresPermissions("jmeter:jmeterNodeJobRel:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(JmeterNodeJobRel jmeterNodeJobRel)
	{
		startPage();
        List<JmeterNodeJobRel> list = jmeterNodeJobRelService.selectJmeterNodeJobRelList(jmeterNodeJobRel);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出节点任务列表
	 */
	@RequiresPermissions("jmeter:jmeterNodeJobRel:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JmeterNodeJobRel jmeterNodeJobRel)
    {
    	List<JmeterNodeJobRel> list = jmeterNodeJobRelService.selectJmeterNodeJobRelList(jmeterNodeJobRel);
        ExcelUtil<JmeterNodeJobRel> util = new ExcelUtil<JmeterNodeJobRel>(JmeterNodeJobRel.class);
        return util.exportExcel(list, "jmeterNodeJobRel");
    }
	
	/**
	 * 新增节点任务
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存节点任务
	 */
	@RequiresPermissions("jmeter:jmeterNodeJobRel:add")
	@Log(title = "节点任务", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(JmeterNodeJobRel jmeterNodeJobRel)
	{		
		return toAjax(jmeterNodeJobRelService.insertJmeterNodeJobRel(jmeterNodeJobRel));
	}

	/**
	 * 修改节点任务
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		JmeterNodeJobRel jmeterNodeJobRel = jmeterNodeJobRelService.selectJmeterNodeJobRelById(id);
		mmap.put("jmeterNodeJobRel", jmeterNodeJobRel);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存节点任务
	 */
	@RequiresPermissions("jmeter:jmeterNodeJobRel:edit")
	@Log(title = "节点任务", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(JmeterNodeJobRel jmeterNodeJobRel)
	{		
		return toAjax(jmeterNodeJobRelService.updateJmeterNodeJobRel(jmeterNodeJobRel));
	}
	
	/**
	 * 删除节点任务
	 */
	@RequiresPermissions("jmeter:jmeterNodeJobRel:remove")
	@Log(title = "节点任务", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(jmeterNodeJobRelService.deleteJmeterNodeJobRelByIds(ids));
	}
	
}
